package day0327;

/**
 * @Author Weton Li
 * @Date 2021/3/27 21:34
 */
public class AnnoymityClass {

    private static int i = 5; // 匿名内部类 私有变量也能访问到
    public void test(){


        new Service(){

            @Override
            public void Service_method2() {
                System.out.println("匿名内部类实现接口方法Service_method2 "+i+" "+j);

            }

            public int j = 10;
            @Override
            public void Service_method1() {

                System.out.println("匿名内部类实现接口方法Service_method1 "+i+" "+j);

            }
        }.Service_method1();

        new Service() {
            @Override
            public void Service_method1() {
                System.out.println("匿名内部类实现接口方法Service_method1 ");
            }

            @Override
            public void Service_method2() {
                System.out.println("匿名内部类实现接口方法Service_method2 ");
            }
        }.Service_method1();
    }

    public static void main(String[] args) {
        new AnnoymityClass().test();
    }
}
